package com.sm.user.controller;

import com.sm.tool.entity.request.PageInfo;
import com.sm.tool.entity.request.UserRegisterRequest;
import com.sm.tool.entity.response.ReturnData;
import com.sm.tool.entity.vo.UserDetailListVO;
import com.sm.tool.entity.vo.UserDetailVO;
import com.sm.tool.entity.vo.UserTicketsVO;
import com.sm.user.service.UserRegLoginService;
import com.sm.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: practice
 * @description: 用户登录注册controller
 * @author: liqitian.
 * @create: 2019-11-15 15:13
 **/
@RestController
@RequestMapping("api/v1/oper")
@Api(tags = "用户相关操作Api", value = "用户相关操作Api",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation(value = "获取某用户基本信息")
    @GetMapping("/get_user_info")
    public ReturnData<UserDetailVO> getUserInfo(
            @Validated
            @RequestHeader
            @ApiParam("用户令牌") String token
    ) {
        return userService.getUserInfo(token);
    }


    @ApiOperation(value = "获取用户列表")
    @PostMapping("/get_user_list")
    public ReturnData<UserDetailListVO> getUserList(
            @RequestHeader
            @ApiParam("管理员令牌") String adminToken,
            @RequestBody PageInfo pageInfo) {
        return userService.getUserList(pageInfo);
    }

    @ApiOperation(value = "用户充值余额",notes = "模拟用户充值")
    @PutMapping("/user_recharge")
    public ReturnData userRecharge(
            @Validated
            @RequestHeader
            @ApiParam("用户令牌") String token
    ) {
        return userService.userRecharge(token);
    }

    @ApiOperation(value = "查看该用户优惠卷",notes = "查看该用户优惠卷")
    @GetMapping("/query_user_tickets")
    public ReturnData<List<UserTicketsVO>> queryUserTickets(
            @Validated
            @RequestHeader
            @ApiParam("用户令牌") String token
    ) {
        return userService.queryUserTickets(token);
    }

}
